#!/bin/sh

mount -t jffs2 /dev/mtdblock4 /mnt

count=0

for file in `ls /mnt/upper  $1`
do
	if [ "$file" != "etc" ]  ; then
		rm -rf /mnt/upper/"$file"
		let count++
		if [ $count -gt 3 ]; then
			break
		fi
	fi
done
cd /
umount /mnt
if [ $count -gt 3 ]; then
	mtd erase /dev/mtd4
fi

